<template>
  <div>this is home page</div>
</template>
<script setup>
import { onMounted } from "vue";
import axios from "axios";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
const router = useRouter();
//做一下身份认证 如果登陆过了 留在当前页面 否则 跳转到登录页面 还是通过发请求(携带cookie)
onMounted(async () => {
  const result = await axios.get("http://localhost:3001/api/admin/whoami");
  if (result.data.status === 0) {
    router.push("/login");
    ElMessage.error("请先登录");
  }
});
</script>
